﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Text;
using System.Data;

namespace XHCTMS.VIEW
{
    public partial class Main : System.Web.UI.Page
    {
        
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Util.SetUserSession.userSession == null)
            {
                Response.Redirect("login.aspx");
            }

            if (!IsPostBack)
            {

                if (Util.SetUserSession.userSession.UserJob == "班主任" || Util.SetUserSession.userSession.UserJob == "学科带头人")
                {
                    AddSubLi();
                    AddClassLi();
                    AddStudentLi();
                    AddFractionLi();
                    AddTeachingLi();
                }
                if (Util.SetUserSession.userSession.UserDep == "教务处" && Util.SetUserSession.userSession.UserTitle == "主管")
                {
                    AddTeachingOperaLi();
                }


            }


        }




        public void AddLi(string controlId ,string innerHtml)
        {
            HtmlGenericControl li = this.FindControl(controlId) as HtmlGenericControl;
            li.InnerHtml = innerHtml;
            li.Attributes.CssStyle.Value = "display:inherit";
        }

        public void AddSubLi()
        {
            AddLi("liSub", "<a href='Sub.aspx' target='show'>专业信息</a>");
        }

        public void AddClassLi()
        {
            AddLi("liClass", "<a href='Class.aspx' target='show'>班级信息</a>");
        }

        public void AddStudentLi()
        {
            AddLi("liStudent", "<a href='Student.aspx' target='show'>学生信息</a>"); 
        }

        public void AddFractionLi()
        {
            AddLi("liFraction", "<a href='Fraction.aspx' target='show'>班级平均分</a>");
        }

        public void  AddTeachingLi()
        {
            StringBuilder sb = new StringBuilder("<a href='#'>授课任务</a><ul>");
            DataTable dtClass = new BLL.Teaching().TeaTeaIDFindClass(int.Parse(Util.SetUserSession.userSession.UserID));
            foreach (DataRow dr in dtClass.Rows)
            {
                sb.Append("<li>" + "<a href='#' id='" + dr[0].ToString() + "'>" + dr[1].ToString()
                    + "</a><ul>");
                DataTable dtTea = new BLL.Teaching().GetTeaching(int.Parse(dr[0].ToString()), int.Parse(Util.SetUserSession.userSession.UserID),false);
                foreach (DataRow drTea in dtTea.Rows)
                {
                    sb.Append("<li><a href ='#'>" + drTea[1].ToString() + "</a>"
                        + "<ul><li><a href ='Checking.aspx?TeachingID="+drTea[0].ToString()+
                        "' target ='show'>考情</a></li><li><a href ='ClassroomPerformance.aspx?TeachingID=" +
                        drTea[0].ToString()+"' target='show'>平时打分</a></li></ul>" + "</li>");
                }

                dtTea = new BLL.Teaching().GetTeaching(int.Parse(dr[0].ToString()), int.Parse(Util.SetUserSession.userSession.UserID), true);
                foreach (DataRow drTea in dtTea.Rows)
                {
                    sb.Append("<li><a href ='#'>" + drTea[1].ToString() + "</a>" +
                        "<ul><li><a href ='Success.aspx?TeachingID=" + drTea[0].ToString() + "' target ='show'>打分</a></li></ul></li>");
                }

                //sb.Append("<li><a href='#'>Ada</a></li>");
                sb.Append("</ul></li>");
            }
            sb.Append("</ul>");
            AddLi("liTeaching", sb.ToString());
        }

        public void AddTeachingOperaLi()
        {
            AddLi("liTeachingOpera", "<a href='Teaching.aspx' target='show'>授课操作</a>");
        }






     

      



    }
}